package com.community.service.impl;

import com.community.common.utils.DateUtils;
import com.community.common.utils.SecurityUtils;
import com.community.domain.BuildingEntity;
import com.community.mapper.BuildingMapper;
import com.community.service.BuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BuildingServiceImpl implements BuildingService {
    @Autowired
    private BuildingMapper buildingMapper;
    @Override
    public List<BuildingEntity> selectBuildingList(BuildingEntity building) {
        return buildingMapper.selectBuildingList(building);
    }

    @Override
    public Integer addBuilding(BuildingEntity building) {
        building.setCreateTime(DateUtils.getNowDate());
        building.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUsername()));
        return buildingMapper.addBuilding(building);
    }

    @Override
    public int updateBuilding(BuildingEntity building) {
        building.setUpdateTime(DateUtils.getNowDate());
        building.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUsername()));
        return buildingMapper.updateBuilding(building);
    }
    @Override
    public int deleteById(int id) {
        return buildingMapper.deleteById(id);
    }

}
